﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using CUREBusinessLogicLayer;

/*************************************************************************************

     * 作   者： 张 颖
  
*************************************************************************************/
namespace CURE.SystemManagement
{
    public partial class userInformation : System.Web.UI.Page
    {
        #region 变量
        
        private string id;

        public string Id
        {
            get { return id; }
            set { id = value; }
        }
        private string master_id;

        public string Master_id
        {
            get { return master_id; }
            set { master_id = value; }
        }
        private string master_userid;

        public string Master_userid
        {
            get { return master_userid; }
            set { master_userid = value; }
        }
        private string master_name;

        public string Master_name
        {
            get { return master_name; }
            set { master_name = value; }
        }
        private string master_password;

        public string Master_password
        {
            get { return master_password; }
            set { master_password = value; }
        }
        private string master_email;

        public string Master_email
        {
            get { return master_email; }
            set { master_email = value; }
        }
        private string master_tel;

        public string Master_tel
        {
            get { return master_tel; }
            set { master_tel = value; }
        }
        
        private string master_dept;

        public string Master_dept
        {
            get { return master_dept; }
            set { master_dept = value; }
        }
        private string master_group;

        public string Master_group
        {
            get { return master_group; }
            set { master_group = value; }
        }
        private string master_sex;

        public string Master_sex
        {
            get { return master_sex; }
            set { master_sex = value; }
        }
        private string action;

        public string Action
        {
            get { return action; }
            set { action = value; }
        }
        string radio;

        public string Radio
        {
            get { return radio; }
            set { radio = value; }
        }
        string group;

        public string Group
        {
            get { return group; }
            set { group = value; }
        }
        string dept;

        public string Dept
        {
            get { return dept; }
            set { dept = value; }
        }
        string job;

        public string Job
        {
            get { return job; }
            set { job = value; }
        }
        string skilllevel;

        public string Skilllevel
        {
            get { return skilllevel; }
            set { skilllevel = value; }
        }
         string skill_transport;

        public string Skill_transport
        {
            get { return skill_transport; }
            set { skill_transport = value; }
        }
        string skill_packaging;

        public string Skill_packaging
        {
            get { return skill_packaging; }
            set { skill_packaging = value; }
        }
        string skill_shipments;

        public string Skill_shipments
        {
            get { return skill_shipments; }
            set { skill_shipments = value; }
        }

        string isEMailRadio;
        public string IsEMailRadio
        {
            get { return isEMailRadio; }
            set { isEMailRadio = value; }
        }

        #endregion

        MasterBll masterBll = new MasterBll();
        protected void Page_Load(object sender, EventArgs e)
        {
            BindForkGroup();
            BindForkDept();
            BindForkJob();
            //BindForkSkilllevel();
            
           
            action = Request.QueryString["action"];
            if (action == "add")//新增
            {
                id = Request.QueryString["id"];
                id = "";
                master_id = "";
                master_name = "";
                txtEmployeeNum.Value = "";

            }
            else if (action == "edit")//编辑 
            {
                id = Request.QueryString["editid"];
                //master_id = Request.QueryString["master_id"];
                DataTable dt = masterBll.GetMaster(id);
                if (dt != null && dt.Rows.Count > 0)
                {
                    //master_oldid = dt.Rows[0]["id"].ToString();
                    master_id = dt.Rows[0]["id"].ToString().Replace(" ", "");
                    master_userid = dt.Rows[0]["userid"].ToString().Replace(" ", ""); 
                    master_name = dt.Rows[0]["name"].ToString().Replace(" ", "");
                    string sex = dt.Rows[0]["sex"].ToString();
                    if (sex != "" && sex != null)
                    {
                        if (sex == "1")
                        {
                            radio = "0";
                        }
                        else
                        {
                            radio = "1";
                        }
                    }
                    //liudan add 12.14
                    string isMail = dt.Rows[0]["isEmail"].ToString();
                    if (isMail != "" && isMail != null)
                    {
                        if (isMail == "1")
                        {
                            isEMailRadio = "1";
                        }
                        else
                        {
                            isEMailRadio = "0";
                        }
                    }

                    dept = dt.Rows[0]["dept_id"].ToString();
                    master_email = dt.Rows[0]["email"].ToString().Replace(" ", "");
                    group = dt.Rows[0]["group_id"].ToString();
                    master_tel = dt.Rows[0]["tel"].ToString();
                    job = dt.Rows[0]["job"].ToString();
                    skilllevel = dt.Rows[0]["skilllevel"].ToString();
                    skill_transport = dt.Rows[0]["skill_transport"].ToString().Replace(" ", "");
                    skill_packaging = dt.Rows[0]["skill_packaging"].ToString().Replace(" ", "");
                    skill_shipments = dt.Rows[0]["skill_shipments"].ToString().Replace(" ", "");

                    txtid.Value = master_id;
                    txtEmployeeNum.Value = master_userid;
                    txtEmployeeNum.Attributes["readonly "] = "readonly";

                }
            }
        }
        /// <summary>
        /// 绑定角色下拉框
        /// </summary>
        protected void BindForkGroup()
        {
            DataTable dt = masterBll.GetGroup();
            if (dt != null && dt.Rows.Count > 0)
            {
                reptGroup.DataSource = dt;
                reptGroup.DataBind();
            }
        }

        /// <summary>
        /// 绑定部门下拉框
        /// </summary>
        protected void BindForkDept()
        {
            DataTable dt = masterBll.GetDept();
            if (dt != null && dt.Rows.Count > 0)
            {
                reptDept.DataSource = dt;
                reptDept.DataBind();
            }
        }

        /// <summary>
        /// 绑定职能下拉框
        /// </summary>
        protected void BindForkJob()
        {
            DataTable dt = masterBll.GetJob();
            if (dt != null && dt.Rows.Count > 0)
            {
                reptJob.DataSource = dt;
                reptJob.DataBind();
            }
        }

        /// <summary>
        /// 绑定等级下拉框
        /// </summary>
        //protected void BindForkSkilllevel()
        //{
        //    DataTable dt = masterBll.GetSkilllevel();
        //    if (dt != null && dt.Rows.Count > 0)
        //    {
        //        reptSkilllevel.DataSource = dt;
        //        reptSkilllevel.DataBind();
        //    }
        //}
    }
}
